<?php
namespace app\index\controller;

use think\Controller;
use think\Db;
class Index extends Controller
{
    public function index()
    {
        return $this->fetch('login');
    }
    public function login()

    {
        //var_dump('ssss');
        $username = I('username');
        $password = I('password');
        //var_dump($username.'##'.$password);die;
        $rs = Db::table('admin_user')->where("username='$username'")->find();
        //var_dump($rs);die;
        if ($rs) {
            if(empty($username)||empty($password)){
                $this->error('账户或密码不能为空');
            }
            if ($rs['password'] == $password) {
                $this->success('登录成功', 'Show/show');
            } else {
                $this->error('密码错误');
            }
        } else {
            $this->error('登录失败');
        }
    }

}
